package com.passer.uam.config;

import com.amihaiemil.eoyaml.YamlMapping;
import com.passer.toolbox.common.password.encryption.Encrypt;
import com.passer.toolbox.common.core.util.YamlUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class UamConfig {

    @Getter
    private static String accountPath;

    @Getter
    private static String accountIndexPath;

    public static void init() {
        Encrypt encrypt = new Encrypt();
        YamlMapping yamlMapping;
        try {
            yamlMapping = YamlUtils.readYamlFile("/uam.yml");
        } catch (IOException e) {
            log.error("读取配置失败：{}", e.getMessage());
            return;
        }
        accountPath = encrypt.decrypt(yamlMapping.value("account").asMapping().string("path"));
        accountIndexPath = encrypt.decrypt(yamlMapping.value("account").asMapping().string("index-path"));
    }
}
